#!/bin/bash
# description:
#	1. cd windows style path in wsl
# 	2. return wsl path in windows style
# Author:
#	Sid Chen
# Date:
#	2022/10/10

show_help () {
	# show help information
	echo winpath [-h] [filename]
	echo ---------------------
	echo 	return path in windows style
}

main () {
	case $1 in
		-h ) show_help ;;
		-c ) 
			Target=$(wslpath -u "$2")
			echo $Target
			cd "$Target"
			;;
		* ) 
			if [ -z $1 ];then
				WinPath=$(wslpath -m $(pwd))
				echo "$WinPath"
				echo "$WinPath" | clip.exe
			else
				WinPath=$(wslpath -m "$(pwd)/$1")
				echo "$WinPath"
				echo "$WinPath" | clip.exe
			fi
	esac
}

if [ $HOSTNAME == "siddor" ];then
	main "$1" "$2"
elif [ $HOSTNAME == "SidNote" ];then
	main "$1" "$2"
else
	echo "only work in WSL"
fi
